<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/pc/jsp/common/common.jsp"%>
<% 
  String userid=(String)CacheClass.isLogin(request,response);
 if(CacheClass.getIntValue(userid)==0)
 {
 	out.println("<script language='JavaScript'>alert('您还没有登陆！');location.href=document.referrer;</script>"); //后退并刷新
 } 

%>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <title>收益记录</title>

</head>
<body class='bcf'>

<div class="of jz" style="width: 90%;margin-top: 24px;" >
   <div id="rmbListDiv">
   
   </div>
 	<!-- 分页 -->
	<div class="c9 f12 lh2 tc mgt30 pageBlock">
		<ul class='db fr of' style="margin-bottom:0px;" id="listPage"></ul>
	</div>
</div>


<script>
var curpage=1;
var taotal=1;

function loadRmbList(curpageForChat)
{
	if(curpageForChat==0) return;
	$.ajax({
            url: "PlugServlet",
            data: JSON.stringify({m:1780,curpage:curpageForChat}),
            type: 'post',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            success: function (data) {
            	console.log(data);
   	           if(data['state']==1)
	           {
	           		curpage=data.curpage*1;
	           		taotal=data.total*1;
	           		
	           		//更新分页
	           		$("#listPage").html('');
	           		if(taotal>1)
 	           		{
		           		var start=1;
		           		if(curpage-3>1)
		           		{
		           			start=curpage-3;
		           		}
		           		var end=taotal;
		           		if(curpage+3<taotal)
		           		{
		           			end=curpage+3;
		           		}
		           		var ChatPageHtml="";
		           		if(curpage!=1)
		           		{   //上一页
		           			ChatPageHtml='<li> <a href="javascript:loadRmbList('+(curpage-1)+');" class="page-up">&lt;&nbsp;上一页</a></li>';
		           		}
		           		for(var i = start;i<end+1;i++)
		           		{
		           			if(i==curpage) //当前页
		           			{
		           				ChatPageHtml=ChatPageHtml+'<li><a href="javascript:void(0);" class="active">'+i+'</a></li>';
		           			}
		           			else
		           			{
		           				ChatPageHtml=ChatPageHtml+'<li><a href="javascript:loadRmbList('+i+');">'+i+'</a></li>';
		           			}
		           		}
		           		if(curpage!=taotal)
		           		{   //下一页
		           			ChatPageHtml=ChatPageHtml+'<li><a href="javascript:loadRmbList('+(curpage+1)+');" class="page-down">下一页&nbsp;&gt;</a></li>';
		           		}
		           		
						$("#listPage").html(ChatPageHtml);
	         		}
	                //数据
	                
	           		
					var contentHtml="";
					if(data.list==null)  return;
	           		$.each(data.list, function(index, objVal) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
	           		    contentHtml=contentHtml+'<div class="shouyiDiv">'+
					        '<div class="clearfix of">'+
					            '<div class="fl">'+
					                '<p class="c3 f20">'+objVal.typename+'</p>'+
					                '<p class="c9 f16" style="margin-top: 16px;">'+objVal.timeAbout+'</p>'+
					            '</div>';
					   if((objVal.rmb*1.0)<0) {        
					            contentHtml=contentHtml+'<div class="fr cgreen" style="margin-top: 15px;">'+
					                '<span class="f21">&yen;</span><span style="font-size: 28px;">'+objVal.rmb+'</span><span class="f25"></span>'+
					            '</div>';
					    } 
					    else
					    {
					    		contentHtml=contentHtml+'<div class="fr cred" style="margin-top: 15px;">'+
					                '<span class="f21">&yen;</span><span style="font-size: 28px;">'+objVal.rmb+'</span><span class="f25"></span>'+
					            '</div>';
					    }     
					            
					     contentHtml=contentHtml+'</div>'+
					    '</div>';
				    });
	           		if(contentHtml=="")
	           			$("#rmbListDiv").html('<p></p><p></p><p></p><p></p>');
	           		else
	           			$("#rmbListDiv").html(contentHtml);
	           
	           }
       		},
            error: function (data) {
                 return false;
            },
         });	
}


$().ready(function() {   
 
    loadRmbList(1);
    
 });
 
</script> 
</body>
</html>